#include <iostream>
#include <iomanip>
using namespace std;
int y,n;
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
void output();

int main()
{
	while(cin>>y>>n){
		output();
		
	}
}

void output()
{
	int i=0;
	int t=n;
	if(y%400==0||(y%4==0&&y%100!=0)) month[1]=29;
	else month[1]=28;
	while(t>month[i]){
		t=t-month[i];
		i++;
	}
	i++;
	cout << setfill('0');
    cout << setw(4)<<y<<"-"<< setw(2) <<i<< "-" << setw(2)  << t<< endl;
}
